package com.example.testactivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class FirstActivity extends Activity {
	// 打开第二个Activity的按钮
	private Button myButton;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		Log.v("FirstActivity", "onCreate");
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_first);
		myButton = (Button) findViewById(R.id.myButton);
		// 设置单击事件
		myButton.setOnClickListener(new ButtonListener());
	}

	@Override
	protected void onStart() {
		super.onStart();
		Log.v("FirstActivity", "onStart");
	}

	@Override
	protected void onResume() {
		super.onResume();
		Log.v("FirstActivity", "onResume");
	}

	@Override
	protected void onPause() {
		super.onPause();
		Log.v("FirstActivity", "onPause");
	}

	@Override
	protected void onStop() {
		super.onStop();
		Log.v("FirstActivity", "onStop");
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		Log.v("FirstActivity", "onDestroy");
	}

	class ButtonListener implements OnClickListener {

		@Override
		public void onClick(View v) {
			Intent intent = new Intent();
			intent.setClass(FirstActivity.this, SecondActivity.class);
			FirstActivity.this.startActivity(intent);
			finish();// 关闭当前Activity
		}

	}

}